<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>不同浏览器的检测和处理</title>
</head>
<body>
<script>
    var browsers = [
        'MSIE',
        'Firefox',
        'Chrome',
        'Safari',
        'Opera'
    ];

    function getBrowserName() {
        var userAgent = navigator.userAgent;
        for (var i = 0; i < browsers.length; i++) {
            if (userAgent.indexOf(browsers[i]) != -1) {
                return browsers[i];
            }
        }
        return 'Unknown';
    }

    function getBrowserVersion() {
        var userAgent = navigator.userAgent;
        var name = getBrowserName();
        var index = userAgent.indexOf(name) + name.length + 1;
        return parseInt(userAgent.substring(index, index + 3));
    }

    var browserName = getBrowserName();
    var browserVersion = getBrowserVersion();

    if (browserName == browsers[0]) {
        if (browserVersion < 9) {
            document.write('Your version of IE　is too old');
        } else {
            document.write('Your version of IE is fully supported')
        }
    }
    for (var i = 1; i < browsers.length; i++) {
        if (browserName == browsers[i]) {
            document.write(browserName + ' is fully supported');
        }
    }
    if (browserName == 'Unknown') {
        document.write('Sorry this browser version is not supported');
    }
</script>
</body>
</html>